package com.ymatou.iapi.sellerproduct.service;


import java.util.Arrays;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import com.ymatou.iapi.productmanager.parameter.QuerySellerProductListResponseBean;
import com.ymttest.business.YmatouAutoTestCall;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.JsonBeanHelper;
import com.ymttest.utils.MapUtil;
import com.ymttest.utils.compare.CallAPI;
import com.ymttest.utils.constant.JsonBeanFile;
/**
*添加长期售卖商品Call
*FreeMaker Template自动生成代码
*/
public class QuerySellerProductListCall extends YmatouAutoTestCall implements CallAPI{
	private static String opurl ="/api/SellerProduct/QuerySellerProductList";
	
	public QuerySellerProductListCall() {
		super(EnvSetup.getSystemUrl("sellerproduct_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		//client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	
	@Override
	public JSONObject callAndReturn(Map<String, Object> paramMap) {
		JSONObject queryProductBean = JsonBeanHelper
				.getJsonBean(JsonBeanFile.QuerySellerProductListTpl);
		JsonBeanHelper.updateJsonBean(queryProductBean, "ProductIdList",new JSONArray(Arrays.asList(paramMap.get("productId").toString())));
		JsonBeanHelper.updateJsonBean(queryProductBean, "SellerId", Integer.parseInt(paramMap.get("sellerId").toString()));
		if (paramMap.keySet().contains("productName")){
			JsonBeanHelper.updateJsonBean(queryProductBean, "ProductName",paramMap.get("productName").toString());
		}
		

		return this.callAndGetReturnData(queryProductBean);
	}
	@Override
	public String getApiName() {
		return "QuerySellerProductList";
	}
	
	
	
	
	
	public static void main(String[] args) throws JsonSyntaxException, JSONException{
		JSONObject beanJsonObject=new QuerySellerProductListCall().callAndReturn(MapUtil.hashMap("sellerId",20336378,"productId","543907b2-5076-48e2-af64-a8b8b451ba3d"));
		Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss").create();
		QuerySellerProductListResponseBean a1= gson.fromJson(beanJsonObject.getJSONObject("Data").toString(), QuerySellerProductListResponseBean.class);

		
		int a=1;
		int c=a;
	}
	
	
	
}